package com.zsd.android.recyclerviewlibrary;

import android.support.v7.widget.RecyclerView;

import com.zsd.android.recyclerviewlibrary.adapter.RViewAdapter;
import com.zsd.android.recyclerviewlibrary.listener.RViewCreate;

public class RViewHelper<T> {

    private RecyclerView recyclerView;
    private RecyclerView.LayoutManager layoutManager;
    private RecyclerView.ItemDecoration itemDecoration;
    private RViewAdapter<T> adapter;
    private int startPageNumber;
    private boolean isSupportPaging;

    public RViewHelper(Builder builder) {
        this.recyclerView = builder.create.createRecyclerView();
        this.layoutManager = builder.create.createLayoutManager();
        this.itemDecoration = builder.create.createItemDecoration();
        this.adapter = builder.create.createAdapter();
        this.startPageNumber = builder.create.startPageNumber();
        this.isSupportPaging = builder.create.isSupportPaging();
        init();
    }

    private void init() {
        recyclerView.setLayoutManager(layoutManager);
        if (itemDecoration != null) {
            recyclerView.addItemDecoration(itemDecoration);
        }
        recyclerView.setAdapter(adapter);
        if (isSupportPaging) {

        }
    }

    public static class Builder<T> {

        private RViewCreate create;

        public Builder(RViewCreate<T> create) {
            this.create = create;
        }

        public RViewHelper build() {
            return new RViewHelper(this);
        }
    }
}
